import '../presenter/library_presenter.dart';
import '../repository/novel_repository.dart';
import 'usecase.dart';

class LibraryGetNovelListUseCase extends UseCase<Future<void>, NoParams> {
  final LibraryPresenter _presenter;
  final NovelRepository _repository;

  LibraryGetNovelListUseCase(this._presenter, this._repository);
  @override
  Future<void> call(NoParams params) async {
    _presenter.recommendRank = await _repository.getRecommendRank();
    _presenter.endBookRank = await _repository.getEndBookRank();
    _presenter.hotRank = await _repository.getHotRank();
    _presenter.hignScore = await _repository.getHighScoreRank();
    _presenter.newCome = await _repository.getNewComeRank();
    _presenter.hotUp = await _repository.getHotUpRank();
    // _presenter.guessYouLike = await _repository.getGuessYouLikeRank();
    _presenter.tagTabs = await _repository.getHotClassifyList();
    if (_presenter.tagIndex == -1) {
      _presenter.tagIndex = int.parse(_presenter.tagTabs.first.classifyId);
    }
    _presenter.novelsByTag =
        await _repository.getNovelListByClass(_presenter.tagIndex.toString());
    _presenter.onComplete();
  }
}
